import axios from 'axios';
import {baseUrl} from '@config/url.js';
let newAxios = axios.create({
  baseURL: baseUrl
});
let baseAxios = {};
// get请求
baseAxios.get = (...params) => {
  return new Promise((resolve, reject) => {
    newAxios.get(...params).then(response => {
      let res = response.data;
      resolve(res, response);
    }).catch(error => {
      console.log(error);
      reject(error);
    });
  });
};

// post请求
baseAxios.post = (url, params) => {
  return new Promise((resolve, reject) => {
    newAxios.post(url, params).then(response => {
      let res = response.data;
      resolve(res, response);
    }).catch(error => {
      reject(error);
    });
  });
};
export default baseAxios;